package com.lpf.crud;

import com.mongodb.*;

/**
 * 不再建议使用
 */
public class MongoCRUDTest {

    public static void main(String[] args) {

        Mongo mongo = new Mongo("127.0.0.1", 27017);
        DB db = new DB(mongo, "testDB_Java_01");
        DBCollection collection = db.getCollection("t_member");

        // 类比法：JDBC,相对来说比较底层
        DBObject dbObject = new BasicDBObject();
        dbObject.put("name", "lpf");
        dbObject.put("age", 28);
        dbObject.put("addr", "浙江杭州");

        collection.insert(dbObject);
        //collection.save(dbObject);

        DBCursor cursor = collection.find();
        for (DBObject obj : cursor) {
            System.out.println(obj);
        }

        // Morphia, MongoDB界的一个ORM鼻祖
        // 后来又有了MongoTemplate
    }

}
